﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlAgilityPack;
using Kooboo.HtmlFunc.Function;
using Kooboo.HtmlFunc.Providers;

namespace Kooboo.HtmlFunc.Analysis.Visitors
{
    public class ListItemLinkVisitor : StartEndVisitor
    {
        public ListItemLinkVisitor(VisitorContext context)
            : base(context, FuncType.ListItemLink)
        {
        }

        protected override object OnQualified(HtmlCommentNode startNode, HtmlCommentNode endNode)
        {
            var list = (IList)this.Context.Items[FuncType.List];

            var linkItem = Provider.Factory.GetProvider<ILinkItem>();
            linkItem.StartNode = startNode;
            linkItem.EndNode = endNode;
            list.LinkItems.Add(linkItem);

            // ret context mark
            return linkItem;
        }

        protected override FuncType RequireType
        {
            get
            {
                return FuncType.List;
            }
        }

        protected override FuncType ExclusiveType
        {
            get
            {
                return this.FuncType;
            }
        }
    }
}
